using System;
using System.ServiceModel;

namespace PSE.Hosting.ServiceHoster.Services.ServiceContracts
{
    /// <summary>
    /// 
    /// </summary>
    [ServiceContract(Namespace = "http://www.bovespa.com.br/ServiceHoster.Service", Name = "IServicesManager", SessionMode = SessionMode.Allowed)]
    public interface IServicesManager
    {
        /// <summary>
        /// Starts all WCF services contained in the assemblies of the specified package.
        /// </summary>
        /// <param name="packageName">The package name containing the assemblies to start.</param>
        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidPackageFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StartPackageAsynchronous")]
        void StartPackageAsynchronous(string packageName, bool startAssemblies);

        /// <summary>
        /// Starts all WCF services contained in the assemblies of the specified package.
        /// </summary>
        /// <param name="packageName">The package name containing the assemblies to start.</param>
        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidPackageFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StartPackage")]
        void StartPackage(string packageName, bool startAssemblies);

        /// <summary>
        /// Stops all WCF services contained in the assemblies of the specified package.
        /// </summary>
        /// <param name="packageName">The package name containing the assemblies to stop.</param>
        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StopPackage")]
        void StopPackage(string packageName, bool save);


        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidAssemblyFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StartAssembly")]
        void StartAssembly(string packageName, string fileName);

        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StopAssembly")]
        void StopAssembly(string packageName, string codeBase);

        /// <summary>
        /// Adds a package to hold assemblies.
        /// </summary>
        /// <param name="packageName"></param>
        [FaultContractAttribute(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.PackageAlreadyExistsFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "AddPackage")]
        void AddPackage(string packageName, string domain, string userName, string password);

        /// <summary>
        /// Adds a package to hold assemblies.
        /// </summary>
        /// <param name="packageName"></param>
        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidPackageFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "UpdatePackage")]
        void UpdatePackage(string packageName, string domain, string userName, string password);

        /// <summary>
        /// Removes a package to hold assemblies.
        /// </summary>
        /// <param name="packageName"></param>
        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidPackageFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "RemovePackage")]
        void RemovePackage(string packageName);

        /// <summary>
        /// Adds as assembly to the Service Hoster.
        /// </summary>
        /// <param name="request">
        /// A Data Contract containing the following fields:
        ///   * PackageName - The package name where the assembly will be added.
        ///   * Assembly
        ///   * CodeBase    - The full path of the assembly to be added.
        ///   * Domain      - 
        /// </param>
        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [FaultContractAttribute(typeof(FaultContracts.InvalidParameterFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "Add")]
        void AddAssembly(DataContracts.AssemblyRequest request);

        /// <summary>
        /// Removes the assembly from the Service Hoster.
        /// </summary>
        /// <param name="packageName"></param>
        /// <param name="assembly"></param>
        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "RemoveAssembly")]
        void RemoveAssembly(string packageName, string assembly);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "Remove")]
        void Remove(System.String packageName, System.String serviceName);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "Start")]
        void Start(DataContracts.ServiceIdentifier request);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "Stop")]
        void Stop(DataContracts.ServiceIdentifier request);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StartWindowsService")]
        void StartWindowsService(bool asynchronous, bool startAll);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "StopWindowsService")]
        void StopWindowsService();

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "GetServicesList")]
        DataContracts.ServiceList GetServicesList(string packageName, string fileName);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "GetAssemblyList")]
        DataContracts.AssemblyList GetAssemblyList(string packageName);

        [FaultContract(typeof(FaultContracts.ServiceFault))]
        [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "GetPackageList")]
        DataContracts.PackageList GetPackageList();
    }
}
